home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1138 / source.zip / FRMMAIL.FRM < prev    next >
Text File  |  1995-01-18  |  6KB  |  213 lines

  1. VERSION 2.00
  2. Begin Form frmmail 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Send Email"
  5.    ClientHeight    =   5304
  6.    ClientLeft      =   2088
  7.    ClientTop       =   2400
  8.    ClientWidth     =   6084
  9.    Height          =   5724
  10.    Left            =   2040
  11.    LinkTopic       =   "Form1"
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   5304
  14.    ScaleWidth      =   6084
  15.    Top             =   2028
  16.    Width           =   6180
  17.    Begin CommandButton cmdcancel 
  18.       Caption         =   "&Cancel"
  19.       Height          =   372
  20.       Left            =   2760
  21.       TabIndex        =   6
  22.       Top             =   4800
  23.       Width           =   972
  24.    End
  25.    Begin CommandButton cmdsend 
  26.       Caption         =   "&Send"
  27.       Enabled         =   0   'False
  28.       Height          =   372
  29.       Left            =   1080
  30.       TabIndex        =   5
  31.       Top             =   4800
  32.       Width           =   972
  33.    End
  34.    Begin TextBox txtmsg 
  35.       Height          =   3252
  36.       Left            =   120
  37.       MultiLine       =   -1  'True
  38.       ScrollBars      =   2  'Vertical
  39.       TabIndex        =   4
  40.       Top             =   1320
  41.       Width           =   5292
  42.    End
  43.    Begin TextBox txtsubj 
  44.       BorderStyle     =   0  'None
  45.       Height          =   372
  46.       Left            =   1200
  47.       TabIndex        =   3
  48.       Top             =   720
  49.       Width           =   3852
  50.    End
  51.    Begin TextBox txtto 
  52.       BorderStyle     =   0  'None
  53.       Height          =   372
  54.       Left            =   1200
  55.       TabIndex        =   2
  56.       Top             =   120
  57.       Width           =   3852
  58.    End
  59.    Begin Label Label2 
  60.       BackColor       =   &H00C0C0C0&
  61.       Caption         =   "Subject:"
  62.       DataField       =   "Subject:"
  63.       Height          =   372
  64.       Left            =   120
  65.       TabIndex        =   0
  66.       Top             =   720
  67.       Width           =   1092
  68.    End
  69.    Begin Label Label1 
  70.       BackColor       =   &H00C0C0C0&
  71.       Caption         =   "To:"
  72.       Height          =   372
  73.       Left            =   120
  74.       TabIndex        =   1
  75.       Top             =   120
  76.       Width           =   1092
  77.    End
  78. End
  79. Option Explicit
  80.  
  81. Sub cmdcancel_Click ()
  82. Dim result As Integer
  83.     If Len(txtmsg.Text) > 0 Then
  84.         result = MsgBox("You will lose any text you entered." + Chr(10) + "Are you sure?", MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2, "Abort message?")
  85.         If result = IDYES Then Unload frmmail
  86.     Else
  87.         Unload frmmail
  88.     End If
  89. End Sub
  90.  
  91. Sub cmdsend_Click ()
  92. Dim uniq As Integer, result As Integer
  93. Dim fout As Integer
  94. Dim fname As String
  95. Dim ptr, column As Integer
  96. Dim msg As String
  97. Dim replyto, organization As String
  98.  
  99.     msg = txtmsg.Text
  100.     
  101. ' Get a unique filename (PBR00N.MSG)
  102.     uniq = Val(GetINI("Message", "LastMessage", "1"))
  103.     uniq = uniq + 1
  104.     SetINI "Message", "LastMessage", Format$(uniq)
  105.     If replytype = 1 Then
  106.         fname = app.Path + "\PBM" + Format$(uniq, "000") + ".MSG"
  107.     Else
  108.         fname = app.Path + "\PBN" + Format$(uniq, "000") + ".MSG"
  109.     End If
  110.  
  111.     fout = FreeFile
  112.     Open fname For Output As fout
  113.  
  114. ' Do headers
  115.     If replytype = 1 Then
  116.         Print #fout, "To: " + txtto.Text
  117.     Else
  118.         Print #fout, "Newsgroups: " + txtto.Text
  119.     End If
  120.     Print #fout, "Subject: " + txtsubj.Text
  121.     If UCase$(GetINI("Message", "PostDate", "Y")) = "Y" Then Print #fout, "Date: " + fixstr(GetGMTime())
  122.     If mailreferences <> "" Then Print #fout, "References: " + mailreferences
  123.     
  124. ' Optional Reply-To
  125.     replyto = GetINI("Message", "Reply-To", "")
  126.     If Len(replyto) > 2 Then Print #fout, "Reply-To: " + replyto
  127.     
  128. ' Optional Organization
  129.     organization = GetINI("Message", "Organization", "")
  130.     If Len(organization) > 2 Then Print #fout, "Organization: " + organization
  131.  
  132. ' Dump message to a file
  133.     Print #fout,    ' Blank line seperates headers from message
  134.     For ptr = 1 To Len(msg)
  135.         column = column + 1
  136.         If column > 70 And Mid$(msg, ptr, 1) = " " Then
  137.         ' Wrap line
  138.             Print #fout,
  139.             column = 0
  140.         Else
  141.             Print #fout, Mid$(msg, ptr, 1);
  142.         End If
  143.     Next ptr
  144.  
  145.     Close fout
  146.     result = Post(fname, replytype) 'post mail or news
  147.     ' Ask about editing again?
  148.     Unload frmmail
  149. End Sub
  150.  
  151. Sub Form_Load ()
  152. Dim sigfname As String
  153. Dim sigout As Integer
  154. Dim sigline As String
  155.  
  156.     frmmail.Width = frmmain.Width * .8
  157.     frmmail.Height = frmmain.Height * .8
  158.     frmmail.Left = (screen.Width - frmmail.Width) / 2
  159.     frmmail.Top = (screen.Height - frmmail.Height) / 2
  160.  
  161.     txtsubj = mailsubject
  162.     txtto = mailsendto
  163.     Form_resize
  164.     If replytype = 1 Then
  165.         label1.Caption = "To:"
  166.         frmmail.Caption = "Send Email"
  167.         cmdsend.Caption = "&Send"
  168.     Else
  169.         label1.Caption = "Newsgroup:"
  170.         frmmail.Caption = "Post News"
  171.         cmdsend.Caption = "&Post"
  172.     End If
  173.  
  174.     ' Do signature
  175.     sigfname = GetINI("Message", "Signature-File", app.Path + "\SIG.TXT")
  176.     If FileExists(sigfname) Then
  177.         sigout = FreeFile
  178.         Open sigfname For Input As sigout
  179.         txtmsg.Text = txtmsg.Text + Chr(13) + Chr(10) + "-- " + Chr(13) + Chr(10)
  180.         While Not EOF(sigout)
  181.             Line Input #sigout, sigline
  182.             txtmsg.Text = txtmsg.Text + sigline + Chr(13) + Chr(10)
  183.         Wend
  184.         Close sigout
  185.         Else
  186.             ' Default signature ?
  187.     End If
  188. End Sub
  189.  
  190. Sub Form_Paint ()
  191.     If txtto = "" Then
  192.         txtto.SetFocus
  193.     ElseIf txtsubj = "" Then
  194.         txtsubj.SetFocus
  195.     Else
  196.         txtmsg.SetFocus
  197.     End If
  198. End Sub
  199.  
  200. Sub Form_resize ()
  201.     txtto.Width = frmmail.ScaleWidth - txtto.Left - 50
  202.     txtmsg.Width = frmmail.ScaleWidth - txtmsg.Left * 2
  203.     txtsubj.Width = txtto.Width
  204.     cmdcancel.Top = frmmail.ScaleHeight - cmdsend.Height
  205.     cmdsend.Top = cmdcancel.Top
  206.     txtmsg.Height = cmdcancel.Top - txtmsg.Top
  207. End Sub
  208.  
  209. Sub txtto_Change ()
  210.     If Len(Trim(txtto.Text)) > 0 Then cmdsend.Enabled = True Else cmdsend.Enabled = False
  211. End Sub
  212.  
  213.